package com.thinkcube.edutainment.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class DocumentViewrFragment extends Fragment {

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		WebView mWebView = new WebView(getActivity());
		if(getArguments().containsKey("Url"))
		{
		String LessonUrl=getArguments().getString("Url");	
		Toast toast = Toast.makeText(getActivity(),
				"Document loading,Please wait", Toast.LENGTH_LONG);
		toast.setGravity(Gravity.CENTER, 200, 200);
		toast.show();
		
		
		mWebView.getSettings().setJavaScriptEnabled(true);
		mWebView.loadUrl("https://docs.google.com/gview?embedded=true&url="+ LessonUrl);
		}
		mWebView.setWebViewClient(new WebViewClient() {
			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				return (false);
			}
		});
		
		return mWebView;
	}

}
